Skip to content

Add .tar.gz / .tgz archive support for extension, preset, and workflow installation#2395

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-tar-gz-support
Draft

Add .tar.gz / .tgz archive support for extension, preset, and workflow installation#2395
Copilot wants to merge 6 commits intomainfrom
copilot/add-tar-gz-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

The extension, preset, and workflow download pipelines only accepted ZIP archives, blocking use of npm registries and CI artifact stores that serve tarballs natively.

Core utilities (extensions.py)

  • _detect_archive_format(url, content_type="") — infers format from URL path extension (.zip, .tar.gz, .tgz) with Content-Type header fallback (application/gzip, application/x-gzip, application/x-tar+gzip)
  • _safe_extract_tarball(archive_path, dest_dir, error_class) — safe extraction with:
    • Pre-extraction validation of all members: rejects absolute paths, .. traversal, symlinks, hard links, and special files
    • Python 3.11: passes pre-validated safe_members list to extractall()
    • Python 3.12+: uses tarfile.data_filter for additional OS-level protection

Extensions & presets

  • install_from_zip() on both managers now detects archive format from the file extension and dispatches to ZIP or tarball extraction accordingly — existing callers are unaffected
  • download_extension() / download_pack() detect format from the download URL (or Content-Type fallback) and persist the archive with the correct extension (.zip or .tar.gz)

__init__.py call sites

Path Change
extension add --from Detects format from URL/Content-Type before saving
preset add --from Same
extension update Inline manifest peek handles both ZIP and tar.gz
workflow add (URL) Extracts workflow.yml from archive when URL points to one
workflow add (local) Accepts local .tar.gz/.tgz/.zip archive files
workflow add (catalog) Same archive detection for catalog-sourced URLs

A shared _extract_workflow_yml(archive_path, fmt) helper handles root-level and single-nested-directory layouts for both formats.

Tests

21 new tests across test_extensions.py and test_presets.py covering: format detection (URL + Content-Type), flat and nested tarball install, missing manifest errors, path traversal rejection, and symlink rejection.

Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 18:04
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 18:06
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 18:09
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 18:12
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 18:14
Copilot AI changed the title [WIP] Add support for .tar.gz and .tgz archives Add .tar.gz / .tgz archive support for extension, preset, and workflow installation Apr 28, 2026
Copilot AI requested a review from mnriem April 28, 2026 18:16
f = tf.extractfile(tf.getmember("workflow.yml"))
if f is not None:
return f.read()
except KeyError:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Support .tar.gz / .tgz archives for extension, preset, and workflow installation

2 participants